package com.tripwego.client.ui.pageVoyage.top;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.tripwego.client.ui.pageVoyage.IVoyageView;

public class TopWidget extends Composite implements IVoyageView {

	private Presenter presenter;

	private EventBus eventBus;

	private HorizontalPanel contentPanel = new HorizontalPanel();

	private TopLeftWidget topLeftWidget;

	private TopCenterWidget topCenterWidget;

	private TopRightWidget topRightWidget;

	public TopWidget() {

		contentPanel.setStyleName("topWidget");
		contentPanel.setWidth("100%");

		topLeftWidget = new TopLeftWidget();
		topLeftWidget.setSpacing(0);
		topLeftWidget.setWidth("");

		topCenterWidget = new TopCenterWidget();

		topRightWidget = new TopRightWidget();
		topRightWidget.setSpacing(0);
		topRightWidget.setSize("", "");

		contentPanel.add(topLeftWidget);
		contentPanel.setCellWidth(topLeftWidget, "30%");
		contentPanel.add(topCenterWidget.asWidget());
		contentPanel.setCellHorizontalAlignment(topCenterWidget.asWidget(), HasHorizontalAlignment.ALIGN_CENTER);
		contentPanel.add(topRightWidget);
		contentPanel.setCellVerticalAlignment(topRightWidget, HasVerticalAlignment.ALIGN_BOTTOM);
		contentPanel.setCellWidth(topRightWidget, "30%");
		contentPanel.setCellHorizontalAlignment(topRightWidget, HasHorizontalAlignment.ALIGN_RIGHT);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.gwt.user.client.ui.Widget#asWidget()
	 */
	@Override
	public Widget asWidget() {
		return contentPanel;
	}

	@Override
	public void setPresenter(Presenter presenter) {
		this.presenter = presenter;

		this.topCenterWidget.setPresenter(presenter);
	}

	@Override
	public void setEventBus(EventBus eventBus) {
		this.eventBus = eventBus;

		this.topCenterWidget.setEventBus(eventBus);
	}

	@Override
	public void init() {
		topCenterWidget.init();
	}
}
